<template>
    <div>
        <div class="home">
            <img alt="Vue logo" src="../assets/logo.png">
            <br>
            <label>用户名</label>
            <el-input v-model="loginData.userName" placeholder="请输入用户名"></el-input>
           <p></p>
            <label>密码</label>
            <el-input :key="passwordType" ref="password" v-model="loginData.password" :type="passwordType" placeholder="请输入密码" show-password></el-input>

            <el-button type="primary" @click="doLogin">登录</el-button>
        </div>
    </div>
</template>

<script>
    import axios from 'axios'

    export default {
        name: "Login",
        data() {
            return {
                loginData: {
                    userName: '',
                    password: ''
                }
            }
        },
        methods: {
            doLogin() {

                var that = this;
                axios
                    .post('http://localhost/doLogin', this.loginData)
                    .then(function (response) {
                        console.log(response);
                        if (response.data == "ok") {
                            that.$router.push({path: './Index'})
                        }

                    })
                    // .error(function (error) {
                    //     console.log(error)
                    // })

            }
        }

    }
</script>

<style scoped>

</style>